﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using TDT_Project.classes;
namespace TDT_Project
{
    public partial class XemDiemPhuHuynh : System.Web.UI.Page
    {
        cls_phuhuynhxemdiem cls = new cls_phuhuynhxemdiem();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    string hocsinh = Request.QueryString["hs"].ToString();
                    string nienkhoa = Request.QueryString["nk"].ToString();
                    string hocky = Request.QueryString["hk"].ToString();
                    string lop = Request.QueryString["lop"].ToString();
                    gvResult.DataSource = cls.Get_Diem_HS(hocky, nienkhoa, hocsinh,lop);
                    gvResult.DataBind();
                    //load thong tin hoc sinh
                    DataSet ds = cls.Get_ThongTin_HS(lop, nienkhoa, hocsinh);
                    if (ds != null && ds.Tables.Count > 0)
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            lbl_hoten.Text = ds.Tables[0].Rows[0]["HoTen"].ToString();
                            lblnamsinh.Text = ds.Tables[0].Rows[0]["NgaySinh"].ToString();
                            lbldiachi.Text = ds.Tables[0].Rows[0]["DiaChi"].ToString();
                            lblnoisinh.Text = ds.Tables[0].Rows[0]["NoiSinh"].ToString();
                            lbllop.Text = ds.Tables[0].Rows[0]["Lop"].ToString();
                            lblnamnhaphoc.Text = ds.Tables[0].Rows[0]["Gioitinh"].ToString();
                          
                        }
                    //end
                    //load hoc luc hoc sinh
                    DataSet ds_hocluc = cls.Get_HOCLUC_HS(lop, nienkhoa, hocsinh,hocky);
                    if (ds_hocluc != null && ds_hocluc.Tables.Count > 0)
                        if (ds_hocluc.Tables[0].Rows.Count > 0)
                        {
                            lblDTB.Text = ds_hocluc.Tables[0].Rows[0]["DiemTB"].ToString();
                            lbl_hang.Text = ds_hocluc.Tables[0].Rows[0]["Hang"].ToString();
                            lbl_dntd.Text = ds_hocluc.Tables[0].Rows[0]["DanhHieuThiDua"].ToString();
                            lbl_loai.Text = ds_hocluc.Tables[0].Rows[0]["hocluc"].ToString();
                            lblhk.Text = ds_hocluc.Tables[0].Rows[0]["hanhkiem"].ToString();
                           
                        }
                    //end
                }
                catch (Exception)
                {

                    throw;
                }

            }
        }

        protected void rdo_HK_SelectedIndexChanged(object sender, EventArgs e)
        {
            string hocsinh = Request.QueryString["hs"].ToString();
            string nienkhoa = Request.QueryString["nk"].ToString();
            //string hocky = Request.QueryString["hk"].ToString();
            string lop = Request.QueryString["lop"].ToString();
            if (rdo_HK.SelectedValue == "0")
            {
                gvResult.DataSource = cls.Get_Diem_HS("HK1", nienkhoa, hocsinh, lop);
                gvResult.DataBind();
                ////load thong tin hoc sinh
                //DataSet ds = cls.Get_ThongTin_HS(lop, nienkhoa, hocsinh);
                //if (ds != null && ds.Tables.Count > 0)
                //    if (ds.Tables[0].Rows.Count > 0)
                //    {
                //        lbl_hoten.Text = ds.Tables[0].Rows[0]["HoTen"].ToString();
                //        lblnamsinh.Text = ds.Tables[0].Rows[0]["NgaySinh"].ToString();
                //        lbldiachi.Text = ds.Tables[0].Rows[0]["DiaChi"].ToString();
                //        lblnoisinh.Text = ds.Tables[0].Rows[0]["NoiSinh"].ToString();
                //        lbllop.Text = ds.Tables[0].Rows[0]["Lop"].ToString();
                //        lblnamnhaphoc.Text = ds.Tables[0].Rows[0]["Gioitinh"].ToString();

                //    }
                ////end
                //load hoc luc hoc sinh
                DataSet ds_hocluc = cls.Get_HOCLUC_HS(lop, nienkhoa, hocsinh, "HK1");
                if (ds_hocluc != null && ds_hocluc.Tables.Count > 0)
                    if (ds_hocluc.Tables[0].Rows.Count > 0)
                    {
                        lblDTB.Text = ds_hocluc.Tables[0].Rows[0]["DiemTB"].ToString();
                        lbl_hang.Text = ds_hocluc.Tables[0].Rows[0]["Hang"].ToString();
                        lbl_dntd.Text = ds_hocluc.Tables[0].Rows[0]["DanhHieuThiDua"].ToString();
                        lbl_loai.Text = ds_hocluc.Tables[0].Rows[0]["hocluc"].ToString();
                        lblhk.Text = ds_hocluc.Tables[0].Rows[0]["hanhkiem"].ToString();
                    }
                    else
                    {
                        lblDTB.Text = "";
                        lbl_hang.Text = "";
                        lbl_dntd.Text = "";
                        lbl_loai.Text = "";
                        lblhk.Text = "";
                    }
                //end
            }
            else
            {
                gvResult.DataSource = cls.Get_Diem_HS("HK2", nienkhoa, hocsinh, lop);
                gvResult.DataBind();
                //load thong tin hoc sinh
                //DataSet ds = cls.Get_ThongTin_HS(lop, nienkhoa, hocsinh);
                //if (ds != null && ds.Tables.Count > 0)
                //    if (ds.Tables[0].Rows.Count > 0)
                //    {
                //        lbl_hoten.Text = ds.Tables[0].Rows[0]["HoTen"].ToString();
                //        lblnamsinh.Text = ds.Tables[0].Rows[0]["NgaySinh"].ToString();
                //        lbldiachi.Text = ds.Tables[0].Rows[0]["DiaChi"].ToString();
                //        lblnoisinh.Text = ds.Tables[0].Rows[0]["NoiSinh"].ToString();
                //        lbllop.Text = ds.Tables[0].Rows[0]["Lop"].ToString();
                //        lblnamnhaphoc.Text = ds.Tables[0].Rows[0]["Gioitinh"].ToString();

                //    }
                //end
                //load hoc luc hoc sinh
                DataSet ds_hocluc = cls.Get_HOCLUC_HS(lop, nienkhoa, hocsinh, "HK2");
                if (ds_hocluc != null && ds_hocluc.Tables.Count > 0)
                    if (ds_hocluc.Tables[0].Rows.Count > 0)
                    {
                        lblDTB.Text = ds_hocluc.Tables[0].Rows[0]["DiemTB"].ToString();
                        lbl_hang.Text = ds_hocluc.Tables[0].Rows[0]["Hang"].ToString();
                        lbl_dntd.Text = ds_hocluc.Tables[0].Rows[0]["DanhHieuThiDua"].ToString();
                        lbl_loai.Text = ds_hocluc.Tables[0].Rows[0]["hocluc"].ToString();
                        lblhk.Text = ds_hocluc.Tables[0].Rows[0]["hanhkiem"].ToString();
                    }
                    else
                    {
                        lblDTB.Text ="";
                        lbl_hang.Text ="";
                        lbl_dntd.Text = "";
                        lbl_loai.Text = "";
                        lblhk.Text = "";
                    }
                //end
            }
        }
    }
}